package com.ctvit.cch.web.controller;

import com.ctvit.cch.core.service.IHotRecordCollectorService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 热榜数据采集Controller
 *
 * @author heyingcheng
 * @date 2025/07/27
 */
@RestController
@RequestMapping("/hot/record/collector")
public class HotRecordCollectorController extends BaseController {

    private final IHotRecordCollectorService hotRecordCollectorService;

    public HotRecordCollectorController(IHotRecordCollectorService hotRecordCollectorService) {
        this.hotRecordCollectorService = hotRecordCollectorService;
    }

    /**
     * 采集各平台热榜数据
     *
     * @param platformCode 平台编码
     * @return {@link AjaxResult } 采集结果
     */
    @PreAuthorize("@ss.hasPermi('hot:record:collector:collect')")
    @Log(title = "热点数据-各平台", businessType = BusinessType.INSERT)
    @PostMapping("platform")
    public AjaxResult collect(@RequestParam String platformCode) {
        return toAjax(hotRecordCollectorService.collectHotRecords(platformCode));
    }

    /**
     * 采集抖音热榜数据
     *
     * @return {@link AjaxResult } 采集结果
     */
    @PreAuthorize("@ss.hasPermi('hot:record:collector:collect')")
    @Log(title = "热点数据-抖音", businessType = BusinessType.INSERT)
    @PostMapping("douyin")
    public AjaxResult collectDouYin() {
        return toAjax(hotRecordCollectorService.collectDouYin());
    }

    /**
     * 采集快手热榜数据
     *
     * @return {@link AjaxResult } 采集结果
     */
    @PreAuthorize("@ss.hasPermi('hot:record:collector:collect')")
    @Log(title = "热点数据-快手", businessType = BusinessType.INSERT)
    @PostMapping("kuaishou")
    public AjaxResult collectKuaiShou() {
        return toAjax(hotRecordCollectorService.collectKuaiShou());
    }

    /**
     * 采集哔哩哔哩热榜数据
     *
     * @return {@link AjaxResult } 采集结果
     */
    @PreAuthorize("@ss.hasPermi('hot:record:collector:collect')")
    @Log(title = "热点数据-哔哩哔哩", businessType = BusinessType.INSERT)
    @PostMapping("bilibili")
    public AjaxResult collectBiLiBiLi() {
        return toAjax(hotRecordCollectorService.collectBiLiBiLi());
    }

    /**
     * 采集好看视频热榜数据
     *
     * @return {@link AjaxResult } 采集结果
     */
    @PreAuthorize("@ss.hasPermi('hot:record:collector:collect')")
    @Log(title = "热点数据-好看视频", businessType = BusinessType.INSERT)
    @PostMapping("haokan")
    public AjaxResult collectHaoKan() {
        return toAjax(hotRecordCollectorService.collectHaoKan());
    }

    /**
     * 采集央视频热榜数据
     *
     * @return {@link AjaxResult } 采集结果
     */
    @PreAuthorize("@ss.hasPermi('hot:record:collector:collect')")
    @Log(title = "热点数据-央视频", businessType = BusinessType.INSERT)
    @PostMapping("yangshipin")
    public AjaxResult collectYangShiPin() {
        return toAjax(hotRecordCollectorService.collectYangShiPin());
    }

}
